﻿//创建时间: 2011-06-16
//创建作者: 李城
//功能说明: CMS系统 内容高级设置 置顶设置 精华设置 排序权重设置 

using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using Newtonsoft.Json;
using System.Text;
using System.Data;
using TRPOP.CMS.Publish;

namespace TRPOP.CMS.Web.Admin
{
    public partial class content_saveAdvance : BaseAdmin
    {

        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_SubPagePermission = Plugin.PermissionKeys.PermissionEnum.Content_AllControl;
        }
        #endregion

        #region 页面变量
        protected int m_intNodeId = 0;
        protected NodeInfo m_NodeInfo = new NodeInfo();
        protected NodeManage m_NodeManage = new NodeManage();
        ModelFieldManage m_ModelFieldManage = new ModelFieldManage();
        protected ContentManage m_ContentManage = new ContentManage();
        protected string m_strAction = "";
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            m_strAction = RequestHelper.RequestString("ac");
            m_intNodeId = RequestHelper.RequestInt("nodeid", 0);
            if (m_strAction.Contains("ajax"))
            {
                //如果是页面二次调用，则异步保存相关的信息
                /*
                 *   内容剪切  内容复制  创建虚链接  创建索引链接    直接从adminselect.aspx页面过来的
                 *   置顶 精华 排序 
                 * 
                 */
                AjaxMethod();
                return;
            }
            switch (m_strAction)
            {
                case "topIt":
                    //显示置顶面板
                    topIt_panel.Visible = true;
                    break;
                case "pinkIt":
                    //显示精华面板
                    pinkIt_panel.Visible = true;
                    break;
                case "sortIt":
                    //显示排序面板
                    sortIt_panel.Visible = true;
                    break;
                default:
                    break;
            }
        }
        #endregion

        #region 页面方法

        private void AjaxMethod()
        {
            JavaScriptObject result = new JavaScriptObject();
            JavaScriptObject items = new JavaScriptObject();
            int m_intparentId = 0, m_intformvaluetypeId = 0;
            EnumSubmitResult enumResult;
            string m_strIds = "";
            switch (m_strAction)
            {
                case "ajax_get_formvalue":
                    //来源 content_save.js
                    #region 获取表单可选值
                    m_intparentId = RequestHelper.RequestInt("id");
                    m_intformvaluetypeId = RequestHelper.RequestInt("tid");
                    if (m_intparentId > 0)
                    {

                        List<FormInputValueInfo> m_FormInputValueInfoList = (new FormInputValueManage()).GetListByCondition(0, " and ParentId=" + m_intparentId + " and FormInputValueTypeId=" + m_intformvaluetypeId, " DisplayOrder asc");
                        foreach (FormInputValueInfo info in m_FormInputValueInfoList)
                        {
                            JavaScriptObject jsOption = new JavaScriptObject();
                            jsOption.Add("text", info.Name);
                            jsOption.Add("value", info.FormInputValueId);
                            items.Add(info.FormInputValueId.ToString(), jsOption);
                        }
                        result.Add("items", items);
                        result.Add("len", m_FormInputValueInfoList.Count);
                        result.Add("result", "1");
                        result.Add("msg", "成功获取");

                    }
                    else
                    {
                        result.Add("result", "-1");
                        result.Add("msg", "参数有误");
                    }
                    #endregion
                    break;
                case "ajax_set_topvalue":
                    //来源 AdminSelect.js
                    #region 置顶
                    int m_intId = RequestHelper.RequestInt("id", 0);//这里的Id 是内容表的Id
                    int m_intTopVal = RequestHelper.RequestInt("topval", 0);
                    base.SaveLog(Plugin.LogKeys.OperObject.InfoOper, Plugin.LogKeys.OperResult.InfoTopval);
                    if (m_intId > 0)
                    {
                        #region 单个操作
                        enumResult = m_ContentManage.SetTopWeightByIds(m_intId.ToString(), m_intTopVal);
                        if (enumResult == EnumSubmitResult.Success)
                        {
                            result.Add("result", "1");
                            result.Add("msg", "ok");
                        }
                        else
                        {
                            result.Add("result", "-1");
                            result.Add("msg", "error");
                        }
                        #endregion
                    }
                    else
                    {
                        #region 批量操作
                        m_strIds = RequestHelper.RequestString("id").Replace("'", "");
                        if (m_strIds != "" && m_strIds.IndexOf(",") > 0)
                        {
                            enumResult = m_ContentManage.SetTopWeightByIds(m_strIds, m_intTopVal);
                            if (enumResult == EnumSubmitResult.Success)
                            {
                                result.Add("result", "1");
                                result.Add("msg", "ok");
                            }
                            else
                            {
                                result.Add("result", "-1");
                                result.Add("msg", "error");
                            }
                        }
                        #endregion
                    }
                    #endregion
                    break;
                case "ajax_set_elitevalue":
                    //来源 AdminSelect.js
                    #region 精华
                    m_intId = RequestHelper.RequestInt("id", 0);//这里的Id 是内容表的Id
                    int m_intEliteVal = RequestHelper.RequestInt("eliteval", 0);
                    base.SaveLog(Plugin.LogKeys.OperObject.InfoOper, Plugin.LogKeys.OperResult.InfoEliteval);
                    if (m_intId > 0)
                    {
                        #region 单个操作
                        enumResult = m_ContentManage.SetEliteWeightByIds(m_intId.ToString(), m_intEliteVal);
                        if (enumResult == EnumSubmitResult.Success)
                        {
                            result.Add("result", "1");
                            result.Add("msg", "ok");
                        }
                        else
                        {
                            result.Add("result", "-1");
                            result.Add("msg", "error");
                        }
                        #endregion
                    }
                    else
                    {
                        #region 批量操作
                        m_strIds = RequestHelper.RequestString("id").Replace("'", "");
                        if (m_strIds != "" && m_strIds.IndexOf(",") > 0)
                        {
                            enumResult = m_ContentManage.SetEliteWeightByIds(m_strIds, m_intEliteVal);
                            if (enumResult == EnumSubmitResult.Success)
                            {
                                result.Add("result", "1");
                                result.Add("msg", "ok");
                            }
                            else
                            {
                                result.Add("result", "-1");
                                result.Add("msg", "error");
                            }
                        }
                        #endregion
                    }
                    #endregion
                    break;
                case "ajax_set_sortvalue":
                    //来源 AdminSelect.js
                    #region 排序
                    m_intId = RequestHelper.RequestInt("id", 0);
                    int m_intSortVal = RequestHelper.RequestInt("sortval", 0);
                    base.SaveLog(Plugin.LogKeys.OperObject.InfoOper, Plugin.LogKeys.OperResult.InfoSortval);
                    if (m_intId > 0)
                    {
                        #region 单个操作
                        enumResult = m_ContentManage.SetDisplayOrderByIds(m_intId.ToString(), m_intSortVal);
                        if (enumResult == EnumSubmitResult.Success)
                        {
                            result.Add("result", "1");
                            result.Add("msg", "ok");
                        }
                        else
                        {
                            result.Add("result", "-1");
                            result.Add("msg", "error");
                        }
                        #endregion
                    }
                    else
                    {
                        #region 批量操作
                        m_strIds = RequestHelper.RequestString("id").Replace("'", "");
                        if (m_strIds != "" && m_strIds.IndexOf(",") > 0)
                        {
                            enumResult = m_ContentManage.SetDisplayOrderByIds(m_strIds, m_intSortVal);
                            if (enumResult == EnumSubmitResult.Success)
                            {
                                result.Add("result", "1");
                                result.Add("msg", "ok");
                            }
                            else
                            {
                                result.Add("result", "-1");
                                result.Add("msg", "error");
                            }
                        }
                        #endregion
                    }
                    #endregion
                    break;
                case "ajax_cut_doc":
                    //来源 content_list.js
                    #region 文章剪切
                    if (m_intNodeId > 0)
                    {
                        base.SaveLog(Plugin.LogKeys.OperObject.InfoOper, Plugin.LogKeys.OperResult.InfoCut);
                        #region 批量操作
                        m_strIds = RequestHelper.RequestString("id").Replace("'", "");
                        if (m_strIds != "")
                        {
                            int intid = Convert.ToInt32(m_strIds.Split(',')[0]);

                            if (intid >= 0)
                            {
                                #region
                                ContentInfo mContentInfo = m_ContentManage.GetInfoById(intid);
                                if (mContentInfo.NodeId != m_intNodeId)
                                {
                                    #region
                                    NodeInfo mNewNodeInfo = (new NodeManage()).GetInfoById(m_intNodeId);
                                    if (mNewNodeInfo != null)
                                    {
                                        #region
                                        NodeInfo mOldNodeInfo = (new NodeManage()).GetInfoById(mContentInfo.NodeId);
                                        if (mOldNodeInfo.ModelId == mNewNodeInfo.ModelId)
                                        {
                                            #region
                                            enumResult = m_ContentManage.CutDocToNewNode(m_strIds, m_intNodeId);
                                            List<ContentInfo> m_ContentInfoList = m_ContentManage.GetListByCondition(0, " AND ContentId IN (" + m_strIds + ") ", "");
                                            foreach (ContentInfo info in m_ContentInfoList)
                                            {
                                                info.NodeId = m_intNodeId;
                                                info.Template = "";
                                                info.PubStatus = 0;
                                                info.TopWeight = 0;
                                                info.EliteWeight = 0;
                                                info.DisplayOrder = 0;
                                                info.Url = m_ContentManage.CreateURL(mNewNodeInfo, info);
                                                // m_ContentManage.Save(info);
                                            }

                                            #region 判断虚结点生成虚链接
                                            if (mNewNodeInfo != null)
                                            {
                                                if (mNewNodeInfo.NodeTypeId == (int)NodeType.EnumElement.TrueNode)
                                                {
                                                    List<NodeInfo> VirualNodeList = m_NodeManage.GetVirualNode(mNewNodeInfo.NodeId);
                                                    foreach (NodeInfo newNodeInfo in VirualNodeList)
                                                    {
                                                        bool m_result = false;
                                                        string msg = "";
                                                        List<ContentInfo> m_VContentInfoList = m_ContentManage.CreateVirtualLink(mNewNodeInfo.NodeId, newNodeInfo.NodeId, m_strIds, out m_result, out msg);

                                                    }
                                                }
                                            }

                                            #endregion
                                            if (enumResult == EnumSubmitResult.Success)
                                            {
                                                result.Add("result", "1");
                                                result.Add("msg", "ok");
                                            }
                                            else
                                            {
                                                result.Add("result", "-1");
                                                result.Add("msg", "error");
                                            }
                                            #endregion

                                        }
                                        else
                                        {
                                            result.Add("result", "-1");
                                            result.Add("msg", "操作失败,目标结点的内容表结构和源文档的内容表结构不符");
                                        }
                                        #endregion
                                    }
                                    else
                                    {
                                        result.Add("result", "-1");
                                        result.Add("msg", "操作失败，原因选择的结点已经不存在了");
                                    }
                                    #endregion

                                }
                                else
                                {
                                    result.Add("result", "1");
                                    result.Add("msg", "ok");
                                }
                                #endregion
                            }
                            else
                            {
                                result.Add("result", "-1");
                                result.Add("msg", "error");
                            }
                        }
                        #endregion
                    }

                    #endregion
                    break;
                case "ajax_copy_doc":
                    //来源 content_list.js
                    #region 文章复制
                    if (m_intNodeId > 0)
                    {

                        base.SaveLog(Plugin.LogKeys.OperObject.InfoOper, Plugin.LogKeys.OperResult.InfoCopy);
                        #region 批量操作
                        m_strIds = RequestHelper.RequestString("id").Replace("'", "");
                        string m_strNewIds = "0";
                        if (m_strIds != "")
                        {

                            NodeInfo mNewNodeInfo = null, mOldNodeInfo = null;
                            ContentManage m_ContentManage = new ContentManage();
                            List<ContentInfo> m_ContentInfoList = m_ContentManage.GetListByCondition(0, " AND ContentId IN (" + m_strIds + ") ", "");
                            List<ModelFieldInfoWithTableName> m_ModelFieldInfoList = new List<ModelFieldInfoWithTableName>();
                            bool blError = false;
                            foreach (ContentInfo info in m_ContentInfoList)
                            {
                                ContentInfo mContentInfo = info;
                                #region 结点信息判断
                                if (mNewNodeInfo == null)
                                {
                                    mNewNodeInfo = (new NodeManage()).GetInfoById(m_intNodeId);
                                    if (mNewNodeInfo == null)
                                    {
                                        result.Add("result", "-1");
                                        result.Add("msg", "操作失败，原因选择的结点已经不存在了");
                                        blError = true;
                                        break;
                                    }
                                }

                                if (mOldNodeInfo == null)
                                {
                                    mOldNodeInfo = (new NodeManage()).GetInfoById(mContentInfo.NodeId);
                                    if (mOldNodeInfo == null)
                                    {
                                        result.Add("result", "-1");
                                        result.Add("msg", "操作失败，原因选择的结点已经不存在了");
                                        blError = true;
                                        break;
                                    }

                                    if (mNewNodeInfo.ModelId != mOldNodeInfo.ModelId)
                                    {
                                        result.Add("result", "-1");
                                        result.Add("msg", "操作失败,目标结点的内容表结构和源文档的内容表结构不符");
                                        blError = true;
                                        break;
                                    }
                                    //m_ModelFieldInfoList = m_ModelFieldManage.GetWithTableNameListByModelId(mNewNodeInfo.ModelId);
                                    foreach (ModelFieldInfoWithTableName FieldInfo in m_ModelFieldManage.GetWithTableNameListByModelId(mNewNodeInfo.ModelId))
                                    {
                                        m_ModelFieldInfoList.Add(FieldInfo.Clone() as ModelFieldInfoWithTableName);
                                    }
                                }


                                #endregion

                                m_ModelFieldInfoList = m_ContentManage.GetContentData(info.ExtendTableName, info.ExtendId, m_ModelFieldInfoList);
                                info.NodeId = m_intNodeId;
                                info.ContentId = 0;
                                info.DisplayOrder = 0;
                                info.TopWeight = 0;
                                info.EliteWeight = 0;
                                info.ExtendId = 0;
                                info.Type = 1;
                                info.PubStatus = 0;//需要根据结点的自动发布设置来操作
                                m_ContentManage.SaveNewDoc(info, m_ModelFieldInfoList);
                                m_strNewIds += "," + info.ContentId;

                            }

                            #region 判断虚结点生成虚链接
                            if (mNewNodeInfo != null)
                            {
                                if (mNewNodeInfo.NodeTypeId == (int)NodeType.EnumElement.TrueNode)
                                {
                                    List<NodeInfo> VirualNodeList = m_NodeManage.GetVirualNode(mNewNodeInfo.NodeId);
                                    foreach (NodeInfo newNodeInfo in VirualNodeList)
                                    {
                                        bool m_result = false;
                                        string msg = "";
                                        List<ContentInfo> m_VContentInfoList = m_ContentManage.CreateVirtualLink(mNewNodeInfo.NodeId, newNodeInfo.NodeId, m_strNewIds, out m_result, out msg);

                                    }
                                }
                            }

                            #endregion

                            if (!blError)
                            {
                                if (mNewNodeInfo.ContentPubTypeId != (int)ContentPubType.EnumElement.NotOutPub && mNewNodeInfo.IsAuoPub)
                                {
                                    result.Add("ids", m_strNewIds);
                                }
                                result.Add("result", "1");
                                result.Add("msg", "ok");
                            }
                        }
                        #endregion
                    }
                    #endregion
                    break;
                case "ajax_delete_doc":
                    //来源 content_list.js
                    #region 批量删除
                    base.SaveLog(Plugin.LogKeys.OperObject.InfoOper, Plugin.LogKeys.OperResult.InfoDelete);
                    m_strIds = RequestHelper.RequestString("id").Replace("'", "");
                    if (m_strIds != "")
                    {
                        List<ContentInfo> m_ContentInfoList = m_ContentManage.GetListByCondition(0, "  AND ContentId IN(" + m_strIds + ") ", " ContentId desc ");
                        foreach (ContentInfo info in m_ContentInfoList)
                        {
                            if (info.PubStatus == (int)PubStatus.EnumElement.Publish
                                && info.Type != (int)LinkType.EnumElement.IndexLink
                                && info.Url != "")
                            {

                                FileUtil.DeleteFile(m_ContentManage.GetContentInfoPSNPath(info), true, "_");//删除发布的页面
                            }
                        }

                        enumResult = m_ContentManage.DeleteInfoByIds(m_strIds);
                        if (enumResult == EnumSubmitResult.Success)
                        {
                            result.Add("result", "1");
                            result.Add("msg", "ok");
                        }
                        else
                        {
                            result.Add("result", "-1");
                            result.Add("msg", "error");
                        }
                    }
                    #endregion
                    break;
                case "ajax_delete_restore":
                    //来源于 recyle_bin.js
                    #region 恢复删除
                    base.SaveLog(Plugin.LogKeys.OperObject.InfoOper, Plugin.LogKeys.OperResult.InfoRestore);
                    m_strIds = RequestHelper.RequestString("id").Replace("'", "");
                    if (m_strIds != "")
                    {
                        enumResult = m_ContentManage.RestoreDeleteInfoByIds(m_strIds);
                        if (enumResult == EnumSubmitResult.Success)
                        {
                            result.Add("result", "1");
                            result.Add("msg", "ok");
                        }
                        else
                        {
                            result.Add("result", "-1");
                            result.Add("msg", "error");
                        }
                    }
                    #endregion
                    break;
                case "ajax_delete_destroy":
                    // 来源于 recyle_bin.js content_search_result.js content_list.js
                    #region 永久删除
                    base.SaveLog(Plugin.LogKeys.OperObject.InfoOper, Plugin.LogKeys.OperResult.InfoDestroy);
                    m_strIds = RequestHelper.RequestString("id").Replace("'", "");
                    bool isDelAttr = RequestHelper.RequestInt("delattr") == 0 ? false : true;
                    bool isDelImg = RequestHelper.RequestInt("delimg") == 0 ? false : true;
                    if (m_strIds != "")
                    {
                        List<ContentInfo> m_ContentInfoList = m_ContentManage.GetListByCondition(0, "  AND ContentId IN(" + m_strIds + ") ", " ContentId desc ");
                        enumResult = EnumSubmitResult.Success;
                        foreach (ContentInfo info in m_ContentInfoList)
                        {
                            enumResult = m_ContentManage.DestroyDeleteInfoById(info, true, isDelAttr, isDelImg);
                        }
                        if (enumResult == EnumSubmitResult.Success)
                        {
                            result.Add("result", "1");
                            result.Add("msg", "ok");
                        }
                        else
                        {
                            result.Add("result", "-1");
                            result.Add("msg", "error");
                        }
                    }
                    #endregion
                    break;
                case "ajax_empty_recycle":
                    // 来源于 recyle_bin.js
                    #region 清空回收站
                    base.SaveLog(Plugin.LogKeys.OperObject.InfoOper, Plugin.LogKeys.OperResult.InfoRecycle);
                    isDelAttr = RequestHelper.RequestInt("delattr") == 0 ? false : true;
                    isDelImg = RequestHelper.RequestInt("delimg") == 0 ? false : true;
                    enumResult = m_ContentManage.EmptyRecycleByNodeId(m_intNodeId, isDelAttr, isDelImg);

                    if (enumResult == EnumSubmitResult.Success)
                    {
                        result.Add("result", "1");
                        result.Add("msg", "ok");
                    }
                    else
                    {
                        result.Add("result", "-1");
                        result.Add("msg", "error");
                    }
                    #endregion
                    break;
                case "ajax_createlink":
                    //来源 content_list.js
                    #region 创建虚链接
                    base.SaveLog(Plugin.LogKeys.OperObject.InfoOper, Plugin.LogKeys.OperResult.InfoCreateLink);
                    string strContentIds = RequestHelper.RequestString("id").Replace("'", "");
                    int intOldNodeId = RequestHelper.RequestInt("oldnodeid");

                    if (m_intNodeId > 0 && intOldNodeId > 0)
                    {

                        m_NodeInfo = m_NodeManage.GetInfoById(m_intNodeId);
                        NodeInfo m_OldNodeInfo = m_NodeManage.GetInfoById(intOldNodeId);
                        if (m_NodeInfo != null && m_OldNodeInfo != null)
                        {

                            if (m_NodeInfo.ModelId != m_OldNodeInfo.ModelId)
                            {
                                #region  判断结点的模型是否一样
                                result.Add("result", "-1");
                                result.Add("msg", "操作失败，原因选择的结点与原来的模型不一致");
                                #endregion
                            }
                            else
                            {
                                #region 开始操作
                                if (strContentIds != "")
                                {
                                    m_ContentManage = new ContentManage();
                                    List<ContentInfo> m_ContentInfoList = m_ContentManage.GetListByCondition(0, " AND ContentId IN (" + strContentIds + ") ", "");
                                    foreach (ContentInfo info in m_ContentInfoList)
                                    {
                                        info.ContentId = 0;
                                        info.NodeId = m_intNodeId;
                                        info.Type = (int)LinkType.EnumElement.VirtualLink;
                                        info.Template = "";
                                        info.PubStatus = 0;
                                        info.TopWeight = 0;
                                        info.EliteWeight = 0;
                                        info.DisplayOrder = 0;
                                        info.PubTime = DateTime.Now;
                                        m_ContentManage.Save(info);

                                        info.Url = m_ContentManage.CreateURL(m_NodeInfo, info);//生成URL
                                        //m_ContentManage.Save(info);
                                        //需要发布设置添加发布操作
                                    }
                                    result.Add("result", "1");
                                    result.Add("msg", "操作成功");
                                }
                                else
                                {
                                    result.Add("result", "-1");
                                    result.Add("msg", "操作失败,原因信息Id为0");
                                }
                                #endregion
                            }
                        }
                        else
                        {
                            result.Add("result", "-1");
                            result.Add("msg", "操作失败,原因信息所属结点或要建链接的结点不存在了");
                        }
                    }
                    else
                    {
                        result.Add("result", "-1");
                        result.Add("msg", "操作失败,原因信息所属结点或要建链接的结点ID为0");
                    }
                    #endregion
                    break;
                case "ajax_createindexlink":
                    //来源 content_list.js
                    #region 创建索引链接
                    base.SaveLog(Plugin.LogKeys.OperObject.InfoOper, Plugin.LogKeys.OperResult.InfoCreateIndexLink);
                    strContentIds = RequestHelper.RequestString("id").Replace("'", "");
                    intOldNodeId = RequestHelper.RequestInt("oldnodeid");

                    if (m_intNodeId > 0 && intOldNodeId > 0)
                    {

                        m_NodeInfo = m_NodeManage.GetInfoById(m_intNodeId);
                        NodeInfo m_OldNodeInfo = m_NodeManage.GetInfoById(intOldNodeId);
                        if (m_NodeInfo != null && m_OldNodeInfo != null)
                        {

                            if (m_NodeInfo.ModelId != m_OldNodeInfo.ModelId)
                            {
                                #region  判断结点的模型是否一样
                                result.Add("result", "-1");
                                result.Add("msg", "操作失败，原因选择的结点与原来的模型不一致");
                                #endregion
                            }
                            else
                            {
                                #region 开始操作 说明索引链接和实链接的URL是一样的。
                                if (strContentIds != "")
                                {
                                    m_ContentManage = new ContentManage();
                                    List<ContentInfo> m_ContentInfoList = m_ContentManage.GetListByCondition(0, " AND ContentId IN (" + strContentIds + ") ", "");
                                    foreach (ContentInfo info in m_ContentInfoList)
                                    {
                                        info.ContentId = 0;
                                        info.NodeId = m_intNodeId;
                                        info.Type = (int)LinkType.EnumElement.IndexLink;
                                        info.Template = "";
                                        info.PubStatus = 0;
                                        info.TopWeight = 0;
                                        info.EliteWeight = 0;
                                        info.DisplayOrder = 0;
                                        m_ContentManage.Save(info);
                                    }
                                    result.Add("result", "1");
                                    result.Add("msg", "操作成功");
                                }
                                else
                                {
                                    result.Add("result", "-1");
                                    result.Add("msg", "操作失败,原因信息Id为0");
                                }
                                #endregion
                            }
                        }
                        else
                        {
                            result.Add("result", "-1");
                            result.Add("msg", "操作失败,原因信息所属结点或要建链接的结点不存在了");
                        }
                    }
                    else
                    {
                        result.Add("result", "-1");
                        result.Add("msg", "操作失败,原因信息所属结点或要建链接的结点ID为0");
                    }

                    #endregion
                    break;
                case "ajax_get_linksdata":
                    //来源 content_save.js
                    #region 获取相关文章信息
                    m_strIds = RequestHelper.RequestString("id").Replace("'", "");
                    if (m_strIds.IndexOf(",") == 0)
                    {
                        m_strIds = m_strIds.Substring(1, m_strIds.Length - 2);
                    }

                    if (m_strIds != "" || m_strIds.IndexOf(",") > 0)
                    {

                        m_ContentManage = new ContentManage();
                        List<ContentInfo> m_ContentInfoList = m_ContentManage.GetListByCondition(0, " AND ContentId IN (" + m_strIds + ") ", "");
                        List<ModelFieldInfoWithTableName> m_ModelFieldInfoList = new List<ModelFieldInfoWithTableName>();
                        try
                        {
                            foreach (ContentInfo info in m_ContentInfoList)
                            {
                                #region 结点信息判断

                                if (m_NodeInfo.NodeId == 0)
                                {
                                    m_NodeInfo = (new NodeManage()).GetInfoById(info.NodeId);
                                    foreach (ModelFieldInfoWithTableName FieldInfo in m_ModelFieldManage.GetWithTableNameListByModelId(m_NodeInfo.ModelId))
                                    {
                                        m_ModelFieldInfoList.Add(FieldInfo.Clone() as ModelFieldInfoWithTableName);
                                    }

                                }
                                #endregion

                                m_ModelFieldInfoList = m_ContentManage.GetContentData(info.ExtendTableName, info.ExtendId, m_ModelFieldInfoList);

                                foreach (ModelFieldInfoWithTableName fieldinfo in m_ModelFieldInfoList)
                                {
                                    if (fieldinfo.IsTitleField)
                                    {
                                        JavaScriptObject item = new JavaScriptObject();
                                        item.Add("id", info.ContentId);
                                        item.Add("title", fieldinfo.DefaultValue);
                                        items.Add(info.ContentId.ToString(), item);
                                        break;
                                    }
                                }

                            }

                            result.Add("result", "1");
                            result.Add("msg", "ok");
                            result.Add("items", items);
                        }
                        catch (Exception error)
                        {
                            result.Add("result", "-1");
                            result.Add("msg", error.Message);
                        }



                    }
                    #endregion
                    break;
                case "ajax_plan_doc":
                    // 来源 content_search_result.js content_list.js
                    #region 更新发布计划
                    base.SaveLog(Plugin.LogKeys.OperObject.InfoOper, Plugin.LogKeys.OperResult.InfoUpDatePlan);
                    m_strIds = RequestHelper.RequestString("id").Replace("'", "");
                    DateTime m_dtPlanDate = Convert.ToDateTime(RequestHelper.RequestString("plandate"));
                    if (m_strIds != "") //&& m_strIds.IndexOf(",") > 0)
                    {
                        enumResult = m_ContentManage.SetPubTimeByIds(m_strIds, m_dtPlanDate);
                        if (enumResult == EnumSubmitResult.Success)
                        {
                            result.Add("result", "1");
                            result.Add("msg", "ok");
                        }
                        else
                        {
                            result.Add("result", "-1");
                            result.Add("msg", "error");
                        }
                    }
                    #endregion
                    break;
                case "ajax_get_contentdata":
                    //来源 admin_main.js
                    #region 获取文章信息
                    m_intId = RequestHelper.RequestInt("id");
                    if (m_intId > 0)
                    {
                        m_ContentManage = new ContentManage();
                        ContentInfo m_info = m_ContentManage.GetInfoById(m_intId);
                        if (m_info != null)
                        {
                            JavaScriptObject jsInfo = new JavaScriptObject();
                            jsInfo.Add("nodeid", m_info.NodeId);
                            jsInfo.Add("contentid", m_info.ContentId);
                            jsInfo.Add("PubStatus", m_info.PubStatus);
                            result.Add("info", jsInfo);
                            result.Add("result", "1");
                            result.Add("msg", "ok");

                        }
                        else
                        {
                            result.Add("result", "0");
                            result.Add("msg", "无效的内容ID");
                        }
                    }
                    else
                    {
                        result.Add("result", "0");
                        result.Add("msg", "无效的内容ID");
                    }
                    #endregion
                    break;
                case "ajax_resetnode_url":
                    #region 更新信息URL
                    if (m_intNodeId > 0)
                    {
                        m_NodeInfo = m_NodeManage.GetInfoById(m_intNodeId);
                        if (m_NodeInfo != null)
                        {
                            List<ContentInfo> m_ContentInfoList = m_ContentManage.GetListByCondition(0, " AND PubStatus>=0  AND Type<>" + (int)LinkType.EnumElement.IndexLink + "  AND NodeId= " + m_intNodeId, " ContentId desc ");
                            foreach (ContentInfo info in m_ContentInfoList)
                            {
                                if (m_NodeInfo.ContentPubTypeId == (int)ContentPubType.EnumElement.NotOutPub)
                                {
                                    info.PubStatus = 0;
                                }
                                m_ContentManage.CreateURL(m_NodeInfo, info);
                            }
                            result.Add("result", "1");
                            result.Add("msg", "更新完成");
                        }
                        else
                        {
                            result.Add("result", "-1");
                            result.Add("msg", "结点不存在");
                        }
                    }
                    else
                    {
                        result.Add("result", "-1");
                        result.Add("msg", "结点ID为０");
                    }
                    #endregion
                    break;
                default:
                    result.Add("result", "1");
                    result.Add("msg", "ok");
                    break;
            }

            Response.Write(JavaScriptConvert.SerializeObject(result));

            base.End();
        }

        #endregion
    }
}
